﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Automobile.service.Common;
using Automobile.service.Model;
using Automobile.service.BLL;
using System.Data;
namespace Automobile.service.UI
{
     
    public partial class EmployeeEdit : System.Web.UI.Page
    {
        EmployeeBLL bll = new EmployeeBLL();
        public void LoadDite()
        {
            DataTable table = bll.Empoyee_Hu(Convert.ToInt32(this.Employee_Id.Value));
            this.Employee_Name.Text = table.Rows[0][1].ToString();
            this.Employee_Pwd.Text = table.Rows[0][2].ToString();
            this.Employee_Phone.Text = table.Rows[0][3].ToString();
            this.Employee_Addr.Text = table.Rows[0][4].ToString();
            if(Convert.ToInt32(table.Rows[0][5])==1)
            {
                this.RadioButton1.Checked =true;
            }
            else
            {
                this.RadioButton2.Checked = true;
            }
            this.Employee_Remark.Text = table.Rows[0][6].ToString();
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            if(!IsPostBack)
            {
               if(Request.QueryString["id"].ToString() != null)
               {
                   this.Employee_Id.Value = Request.QueryString["id"].ToString();
                   LoadDite();
               }
            }
        }

        protected void Unnamed1_Click(object sender, EventArgs e)
        {
            Employee es = new Employee();
            es.Employee_Id = Convert.ToInt32(Request.QueryString["id"]);
            es.Employee_Name = this.Employee_Name.Text;
            es.Employee_Phone = this.Employee_Phone.Text;
            es.Employee_Pwd = this.Employee_Pwd.Text;
            es.Employee_Remark = this.Employee_Remark.Text;
            es.Employee_Addr = this.Employee_Addr.Text;
            es.Employee_State = this.RadioButton1.Checked ? 1 : 0;
            if(bll.Empoyee_Upt(es)>0)
            {
                Response.Write("修改成功");
                Response.Redirect("EmployeeShow.aspx");
            }
            else
            {
                Response.Write("修改失败");
            }

        }

        protected void RadioButton1_CheckedChanged(object sender, EventArgs e)
        {

        }

        protected void RadioButton2_CheckedChanged(object sender, EventArgs e)
        {

        }
    }
}